package com.xmwzw.catpu.bean;

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.os.Parcel;
import android.os.Parcelable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

/**
 * @author : wangzw
 * @date : 20-3-31上午11:37
 * @desc :
 */
public class SoftBean extends BaseObservable implements Parcelable {
    public String id;
    @Bindable
    public String no;
    @Bindable
    public String icon_url;
    @Bindable
    public String name;
    @Bindable
    public String version;
    @Bindable
    public String downloadNo="获取次数:0";

    public String type_id;

    public String type_name;

    public String down_url;

    public SoftBean() {
    }

    protected SoftBean(Parcel in) {
        id = in.readString();
        no = in.readString();
        icon_url = in.readString();
        name = in.readString();
        version = in.readString();
        downloadNo = in.readString();
        type_id = in.readString();
        type_name = in.readString();
        down_url = in.readString();
    }

    public static final Creator<SoftBean> CREATOR = new Creator<SoftBean>() {
        @Override
        public SoftBean createFromParcel(Parcel in) {
            return new SoftBean(in);
        }

        @Override
        public SoftBean[] newArray(int size) {
            return new SoftBean[size];
        }
    };

    @BindingAdapter({"imageUrl"})
    public static void loadImage(ImageView imageView, String url){
        Glide.with(imageView.getContext()).load(url)
                .into(imageView);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(id);
        parcel.writeString(no);
        parcel.writeString(icon_url);
        parcel.writeString(name);
        parcel.writeString(version);
        parcel.writeString(downloadNo);
        parcel.writeString(type_id);
        parcel.writeString(type_name);
        parcel.writeString(down_url);
    }
}
